﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels;
using System.Runtime.Serialization.Formatters;
using System.Collections;

namespace GameServer
{
    class Server
    {       
        private TcpChannel remotingChannel;       
        private int tcpPortNumber = 7878;

        public Server()
        {
            BinaryClientFormatterSinkProvider bcfs = null;
            BinaryServerFormatterSinkProvider bsfs = new BinaryServerFormatterSinkProvider();

            IDictionary dictionary = new Hashtable();

            bsfs.TypeFilterLevel = TypeFilterLevel.Full;
            dictionary = new Hashtable();
            dictionary["port"] = tcpPortNumber;
            dictionary["typeFilterLevel"] = TypeFilterLevel.Full;
            dictionary["name"] = System.Guid.NewGuid().ToString();
            TcpPort = tcpPortNumber;
            remotingChannel = new TcpChannel(dictionary, bcfs, bsfs);
            ChannelServices.RegisterChannel(remotingChannel, false);
            dictionary.Clear();
            dictionary = null;
        }

        public int TcpPort { get; set; }
    }
}
